package cn.xuchunh.campusbbs.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.facebook.drawee.view.SimpleDraweeView;

import cn.xuchunh.campusbbs.R;
import cn.xuchunh.campusbbs.base.BaseActivity;
import cn.xuchunh.campusbbs.ui.fragments.ImageFragment;

/**
 * Created by XuChunH on 2015/9/18.
 */
public class ImageActivity extends FragmentContainerActivity<ImageFragment> {

    public static final String TAG = ImageActivity.class.getSimpleName();

    private Uri uri;

    public static void launch(Context context, Uri uri) {
        Intent intent = new Intent(context, ImageActivity.class);
        intent.setData(uri);
        context.startActivity(intent);
    }

    @Override
    protected ImageFragment getFrament() {
        return ImageFragment.newInstance(uri);
    }

    @Override
    protected int containerId() {
        return R.id.container;
    }

    @Override
    protected void beforeInitView() {

        uri = getIntent().getData();

        Log.d(TAG, uri.toString());
        setShowHomeUp(true);

    }

    @Override
    protected void initView(View view) {
        view.setBackgroundColor(getResources().getColor(R.color.dark_theme_background));
        view.setFitsSystemWindows(true);
        super.initView(view);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int createContentRes() {
        return R.layout.layout_simple_container;
    }

}
